﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using OfficeOpenXml;
using OfficeOpenXml.Table;

namespace shop.Web.Common
{
    /// <summary> 数据导出到sheet的设置 </summary>
    public class SheetExportConfig
    {
        /// <summary> 数据导出到sheet的设置 </summary>
        public SheetExportConfig(ExcelWorksheet sheet)
        {
            this.Sheet = sheet;
        }

        /// <summary> 表格 </summary>
        public ExcelWorksheet Sheet { set; get; }

        /// <summary> 大标题 </summary>
        public string Title { set; get; }

        /// <summary> 小标题 </summary>
        public string SubTitle { set; get; }

        /// <summary> 数据 </summary>
        public List<DataTable> Tables { set; get; }

        /// <summary> 数据 </summary>
        public object DataList { set; get; }

        /// <summary> 泛型数据的类型 </summary>
        public Type DataListType { set; get; }


        /// <summary> 末尾备注, 使用靠左对其,不用合并单元格 </summary>
        public string FooterText { set; get; }

        /// <summary> 列名称 </summary>
        public Dictionary<string, string> ColumnsDict { set; get; }

        /// <summary> 列名称, 多行列 </summary>
        public DataTable ColumnsTable { set; get; }

        /// <summary> 是否打印列标题 </summary>
        public bool PrintColumnHeader { set; get; } = true;

        /// <summary> 列标题内容起始行 (只在ExcelHelper中使用) </summary>
        public int ColumnsRowIndex { set; get; }

        /// <summary> 起始行 </summary>
        public int BeginRowIndex { set; get; } = 1;


        /// <summary> 表格结束填入输入后的最后一行 </summary>
        public int EndRowIndex { set; get; } = 1;



        /// <summary> 列的单元格格式 </summary>
        public Dictionary<int, string> ColumnFormats { set; get; }

        /// <summary> 列的单元格格式, 使用名称指定列 </summary>
        public Dictionary<string, string> ColumnFormats2 { set; get; }


        /// <summary> 导出数据的样式 </summary>
        public TableStyles Style { set; get; } = TableStyles.None;

        /// <summary> 指定导出数据的成员 （当数据是List时使用） </summary>
        public MemberInfo[] Members { set; get; }

        /// <summary> 将数据分栏的栏数 </summary>
        public int MultyColumns { get; internal set; } = 1;


        /// <summary> 分栏中间是否要留空白 </summary>
        public bool BlankInMultyColumns { set; get; } = true;

        /// <summary> 分栏后每栏的列数量 </summary>
        public int Cs { set; get; }

        /// <summary> 在填入数据后加入自定义的方法 </summary>
        public Action<SheetExportConfig> AfterInsertDataAction { set; get; }

        /// <summary> 数据跨列的信息 </summary>
        public Dictionary<int, int> SpanColumns { get; set; }

    }
}